import Vue from 'vue'
import Vuex from 'vuex'
import DetailModule from "./modules/DetailModule";
import CityNameModule from "./modules/CityNameModule";
import CinemaModule from "./modules/CinemaModule";
import BannerModule from "./modules/BannerModule";
import FirstPageModule from "./modules/FirstPageModule";
import SecondPageModule from "./modules/SecondPageModule";
import InforModule from "./modules/InforModule";
// import createPersistedState from "vuex-persistedstate"
//npm install vuex-persistedstate --save
Vue.use(Vuex)

const store = new Vuex.Store({
  // plugins: [createPersistedState()],
  state: {
    //公共资源
    isShowTab: true,
    cityName: "北京",
    cityId: "110100",
    firstCityId: "110100",
    secondCityId: "110100",
  },
  mutations: {
    hideTab(state) {
      state.isShowTab = false;
    },
    showTab(state) {
      state.isShowTab = true;
    },
    cityName(state, cityName) {
      state.cityName = cityName;
    },
    cityId(state, cityId) {
      state.cityId = cityId;
    },
    firstCityId(state, firstCityId) {
      state.firstCityId = firstCityId;
    },
    secondCityId(state, secondCityId) {
      state.secondCityId = secondCityId;
    },
  },
  //处理异步操作
  actions: {
  },
  modules: {
    DetailModule,
    CityNameModule,
    CinemaModule,
    BannerModule,
    FirstPageModule,
    SecondPageModule,
    InforModule
  }
})
export default store;